package com.liuwei.spring.cloud.common.utils.feishu.element;/**
 * @author : Elements
 * @version V1.0
 * @date: 2023/5/26 9:59 上午
 * @Description: TODO
 */

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

import java.util.List;

/**
 * @author : Elements
 * @version V1.0
 * @date: 2023/5/26 9:59 上午
 * @Description: TODO
 */
public class Elements {

    @Data
    public static class BaseFeishuElement {

    }

    @Data
    public static class PlainTextElement extends BaseFeishuElement {
        private String content;
        private String tag = "plain_text";

        public PlainTextElement(String content){
            this.content = content;
        }
    }

    @Data
    public static class MdElement extends BaseFeishuElement {
        private String content;
        private String tag = "lark_md";

        public MdElement(String content){
            this.content = content;
        }
    }

    @Data
    public static class AlinkElement extends BaseFeishuElement {
        private String text;
        private String href;
        private String tag = "a";

        public AlinkElement(String text,String href){
            this.text = text;
            this.href = href;
        }
    }

    @Data
    public static class AtElement extends BaseFeishuElement {
        private String tag = "at";

        @JsonProperty(value = "user_id")
        private String users;

        public AtElement(String users){
            this.users = users;
        }
    }

    @Data
    public static class DivElement extends BaseFeishuElement {
        private String tag = "div";
        private MdElement text;
    }

    @Data
    public static class ActionElement extends BaseFeishuElement {
        private String tag = "action";
        private List<BaseFeishuElement> actions;
    }

    @Data
    public static class ButtonElement extends BaseFeishuElement {
        private String tag = "button";
        private MdElement text;
        private String type = "default";
        private String url;
        private Object value = new Object();

        public ButtonElement(String desc,String url){
            this.text = new MdElement(desc);
            this.url = url;
        }
    }
}
